# Huawei Technologies Co.,Ltd.

set(ECMA_EMPTY_CLASS_CHECK_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ecma_empty_class_check_out.txt)
set(ECMA_EMPTY_CLASS_CHECK_BIN ${CMAKE_CURRENT_BINARY_DIR}/ecma_empty_class_check.abc)
set(ECMA_EMPTY_CLASS_CHECK_JS ${CMAKE_CURRENT_SOURCE_DIR}/ecma_empty_class_check.js)
set(ECMA_EMPTY_CLASS_CHECK_SAMPLE ${CMAKE_CURRENT_SOURCE_DIR}/ecma_empty_class_check_sample.txt)

set(RUNTIME_ARGUMENTS
    --load-runtimes=ecmascript
    ${ECMA_EMPTY_CLASS_CHECK_BIN}
    _GLOBAL::func_main_0
)

add_custom_target(ecma_empty_class_check_es2panda
    COMMENT "running es2panda javascript ecma_empty_class_check testcase"
    COMMAND rm -f ${ECMA_EMPTY_CLASS_CHECK_BIN}
    COMMAND ${es2panda_bin} ${ECMA_EMPTY_CLASS_CHECK_JS} --output ${ECMA_EMPTY_CLASS_CHECK_BIN}
    DEPENDS ${es2panda_target}
)

add_custom_target(ecma_empty_class_check_ark
    COMMENT "running ark javascript ecma_empty_class_check testcase"
    COMMAND rm -f ${ECMA_EMPTY_CLASS_CHECK_OUTPUT}
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:ark> ${RUNTIME_ARGUMENTS} > ${ECMA_EMPTY_CLASS_CHECK_OUTPUT}
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:ark> ${RUNTIME_ARGUMENTS} --gc-type=stw
    DEPENDS ecma_empty_class_check_es2panda ark
)

add_custom_target(ecma_empty_class_check_check_out
    COMMENT "Check output javascript ecma_empty_class_check testcase"
    COMMAND ${CMAKE_COMMAND} -E compare_files ${ECMA_EMPTY_CLASS_CHECK_OUTPUT} ${ECMA_EMPTY_CLASS_CHECK_SAMPLE}
    DEPENDS ecma_empty_class_check_ark
)

add_dependencies(ecmascript_common_tests ecma_empty_class_check_check_out)

panda_ecmascript_add_gtest(
    NAME ecma_empty_class_check
    SOURCES
        ecma_empty_class_check.cpp
    LIBRARIES
        arkruntime
    DEPS_TARGETS
        ecma_empty_class_check_es2panda
    SANITIZERS
        ${PANDA_SANITIZERS_LIST}
)
